package com.sb.framework.config;

import com.alan.validate.aop.ParamValidateBean;
import org.apache.log4j.Logger;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.sb.framework.exception.handler.SystemExceptionHandler;
import com.sb.framework.util.WebUtil;

@Configuration
public class InitBeanConfig {

	private Logger logger = Logger.getLogger( InitBeanConfig.class );

	/**
	 * 异常处理器 SystemExceptionHandler
	 * 
	 */
	@Bean(name = "systemExceptionHandler")
	SystemExceptionHandler systemExceptionHandler() {
		logger.info( "SystemExceptionHandler init start...." );
		SystemExceptionHandler systemExceptionHandler = new SystemExceptionHandler();
		systemExceptionHandler.setErrLogPath("D:/logs_err.log");
		systemExceptionHandler.setErrorViewName("sysError");
		systemExceptionHandler.setErrMessageName("message");
		systemExceptionHandler.setErrCodeName("code");
		return systemExceptionHandler;
	}

	/**
	 * 配置SystemErrorEvent Publisher
	 */
	/*@Bean(name = "SystemErrorPublisher")
	ApplicationEventPublisherAware createApplicationEventPublisher() {
		logger.debug( "SystemErrorPublisher init start...." );
		return new SystemErrorException.SystemErrorEventPublisher();
	}*/

	@Bean(name = "webUtil")
	WebUtil webUtil() {
		logger.info( "webUtil init start...." );
		return new WebUtil();
	}

	/*@Bean
	SystemErrorEventListener systemErrorEventListener() {
		logger.debug( "SystemErrorEventListener init start...." );
		return new SystemErrorEventListener();
	}*/
	
	@Bean
	ParamValidateBean paramValidateBean(){
		return new ParamValidateBean();
	}

}
